package listo.utils.logging;

public class ConsoleLog implements Log {

    public void log(Level level, String message, Object... args) {
        switch (level) {
            case DEBUG:
                debug(message, args);
                break;
            case ERROR:
                error(message, args);
                break;
            case FATAL:
                fatal(message, args);
                break;
            case INFO:
                info(message, args);
                break;
            case TRACE:
                trace(message, args);
                break;
            case WARN:
                warn(message, args);
                break;
        }
    }

    public void mark() {
        trace("*** MARK ***");
    }

    public void trace(String message, Object... args) {
        System.out.print("TRACE: ");
        print(message, args);
    }

    public void debug(String message, Object... args) {
        System.out.print("DEBUG: ");
        print(message, args);
    }

    public void info(String message, Object... args) {
        System.out.print("INFO : ");
        print(message, args);
    }

    public void warn(String message, Object... args) {
        System.out.print("WARN : ");
        print(message, args);
    }

    public void error(String message, Object... args) {
        System.out.print("ERROR: ");
        print(message, args);
    }

    public void fatal(String message, Object... args) {
        System.out.print("FATAL: ");
        print(message, args);
    }

    private void print(String message, Object... args){
        System.out.println(String.format(message, args));
    }

}
